<?php
class NewsItem extends MainObject {

	protected $_dateAdd = '';

	protected $_title = '';

	protected $_text = '';

	protected $_visible = true;

	protected $_sticky = true;

	public function  __construct($newsId = null) {
		$this->_model = new NewsItemObjModel();
		if($newsId) {
			$newsItemData = $this->_model->getNewsItem($newsId);
			foreach ($newsItemData as $data) {
				$this->_id = $data->id;
				$this->_dateAdd = $data->date_add;
				$this->_visible = $data->visible;
				$this->_title = $data->title;
				$this->_text = $data->text;
				$this->_sticky = $data->sticky;
			}
		}
	}

	public function setAddDate($date) {
		$this->_dateAdd = $date;
	}

	public function setTitle($title) {
		$this->_title = $title;
	}

	public function setText($text) {
		$this->_text = $text;
	}

	public function setVisible($visible) {
		$this->_visible = $visible;
	}

	public function setSticky($sticky) {
		$this->_sticky = $sticky;
	}

	protected function _save() {
		$this->_model->save($this);
	}

	public function getTitle() {
		return $this->_title;
	}

	public function getText() {
		return $this->_text;
	}

	public function getVisible() {
		return $this->_visible;
	}

	public function getStick() {
		return $this->_sticky;
	}

	public function getDateAdd() {
		return $this->_dateAdd;
	}

	protected function _update() {
		$this->_model->update($this);
	}
}